package edu.gxnu.cetcdemo.controller;

import edu.gxnu.cetcdemo.pojo.Materials;
import edu.gxnu.cetcdemo.service.MaterialsService;
import edu.gxnu.cetcdemo.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/materials")
public class MaterialsController {
    @Autowired
    private MaterialsService materialsService;

    @ApiOperation("浏览物资列表接口")
    @GetMapping("")
    public Result queryMaterialsList(){
        return materialsService.queryMaterialsList();
    }

    @ApiOperation("添加物资接口")
    @PostMapping("")
    public Result addMaterials(@RequestBody Materials materials){
        return materialsService.addMaterials(materials);
    }

    @ApiOperation("更新物资接口")
    @PutMapping("")
    public Result updateMaterials(@RequestBody Materials materials){
        return materialsService.updateMaterials(materials);
    }

    @ApiOperation("删除物资接口")
    @DeleteMapping("/{id}")
    public Result delMaterials(@PathVariable long id){
        return materialsService.delMaterials(id);
    }
}
